package com.ethan.cj.ssm.service.impl;

import com.ethan.cj.ssm.dao.TestDao;
import com.ethan.cj.ssm.entity.TestEntity;
import com.ethan.cj.ssm.service.TestService;
import com.ethan.cj.ssm.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestServiceImpl implements TestService {

    @Autowired
    private TestDao td;

    @Override
    public TestEntity selectTestEntityByName(String name) {
        return td.selectTestEntityByName(name);
    }

    @Override
    public TestEntity selectTestEntityById(int id) {
        return td.selectTestEntityById(id);
    }

    @Override
    public List<TestEntity> list() {
        return td.list();
    }

    @Override
    public PageBean<TestEntity> pageList(PageBean<TestEntity> pb, String name) {
        int count = td.count(name);
        List<TestEntity> list = td.pageList(name, pb.getOffset(), pb.getPageSize());
        pb.setList(list);
        pb.setTotalCount(count);
        return pb;
    }

    @Override
    public int delete(int id) {
        return td.delete(id);
    }

    @Override
    public int update(TestEntity te) {
        return td.update(te);
    }

    @Override
    public int insert(TestEntity te) {
        return td.insert(te);
    }
}
